function Food(el){
   // 1.保存地图对象  
this.el=el
// 2.保存食物属性
this.len=20
this.gho=20
this.foodObj = null
this.foodX = 0
this.foodY = 0

}
Food.prototype.create=function(){
//   创建div标签对象
let divObj=document.createElement('div')
// 设置样式
divObj.style.width = this.len + 'px'
divObj.style.height = this.gho + 'px'
divObj.style.background = 'green'
divObj.style.position = 'absolute'
this.foodObj=divObj
this.el.appendChild(divObj)
this.move()
}
Food.prototype.move=function(){
let foodXMaxNum=this.el.clientWidth/this.len-1
let foodYMaxNum=this.el.clientHeight/this.len-1
this.foodX = Math.floor(Math.random() * (foodXMaxNum-0+1)+0) * this.len
this.foodY = parseInt(Math.floor(Math.random() * (foodYMaxNum-0+1)+0) * this.len)
console.log(this.foodX)
console.log(this.foodY)
this.foodObj.style.left=this.foodX + 'px'
this.foodObj.style.top=this.foodY + 'px'
}